<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="signTable" lay-filter="signTable"></table>
                    <script type="text/html" id="signData">
                        <div class="layui-btn-container">
                        </div>
                    </script>

                    <script type="text/html" id="signBar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">打卡</a>
                    </script>

                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>layui.use('laydate',
    function () {
    });</script>
<script>layui.use('table',
    function () {
        var table = layui.table;

        layui.use(['table','layer'], function () {
             table = layui.table
             layer = layui.layer;

            table.render({
                elem: '#signTable'
                , url: '/student/signTask'
                , toolbar: '#signData' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                    title: '提示'
                    , layEvent: 'LAYTABLE_TIPS'
                    , icon: 'layui-icon-tips'
                }]
                , page: true
                , title: '员工数据表'
                , curr: 1
                , limit: 8
                , limits: [5, 8, 10, 12, 14]
                , cols: [[
                    /*{type: 'checkbox', fixed: 'left'}*/
                    {field: 'taskId', title: '任务ID', width: 100, fixed: 'left', unresize: true, sort: true}
                    , {field: 'stuId', title: '学生ID', width: 100}
                    , {field: 'stuName', title: '学生名称', width: 200}
                    , {field: 'taskName', title: '任务名称', width: 180}
                    , {field: 'taskContent', title: '任务内容', width: 450}
                    , {field: 'taskAdmin', title: '发布者', width: 150}
                    , {field: 'taskAndTime', title: '结束时间', width: 150}

                    , {field: 'flagTask', title: '是否完成', width: 150,templet: function(res){
                        return res.flagTask=='0'?'<em>未完成</em>':'<em>已完成</em>'
                      }}
                    , {fixed: 'right', title: '操作', toolbar: '#signBar', width: 200}
                ]]
            });



            //监听行工具事件
            table.on('tool(signTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    /*layer.confirm('真的删除行么', function (index) {
                        $.ajax({
                            type:"delete",
                            url:"/employee/emp",
                            data:{
                                empId:data.empId
                            },
                            dataType:"json",
                            success:function (res) {
                                if (res.code==0){
                                    layer.msg("删除员工成功")
                                } else {
                                    layer.msg("删除员工失败")
                                }
                            },
                            error:function (res) {
                                layer.msg("你没有权限")
                            }
                        })
                        layer.close(index);
                    });*/
                } else if (obj.event === 'edit') {
                    $.ajax({
                        type:"post",
                        url:"/student/sign",
                        data:{
                            taskId:data.taskId,
                            taskAndTime:data.taskAndTime
                        },
                        success:function (res) {
                            if (res.code==0){
                                layer.msg(res.msg)
                            } else {
                                layer.msg(res.msg)
                            }
                        }

                    })

                }
            });
        });


        $(".addSign").click(function () {
            var index = layer.open({
                        type: 2,
                        area: [$(window).width() * 0.7 + 'px', $(window).height() - 100 + 'px'],
                        fix: false, //不固定
                        maxmin: true,
                        shadeClose: true,
                        shade: 0.4,
                        title: "添加任务",
                        content: "./task-add.html",
                        success: function () {

                        }
                    })



        })












    });</script>


</html>